package com.ymatou.iapi.userservice.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.userservice.parameter.MobileexistsBean;
import com.ymatou.iapi.userservice.parameter.req.CreateUserReq;
import com.ymatou.iapi.userservice.service.MobileexistsCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.JUserCallService;
import com.ymttest.database.model.Userinfo;
import com.ymttest.database.sqlwapper.JUserWapper;
import com.ymttest.utils.TestDataManager;
/**
*查询登录邮箱是否存在
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_Mobileexists{
	private static MobileexistsBean mobileexistsBean;
	private static MobileexistsCall mobileexistsCall;
	private static JUserWapper jUserWapper;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询登录邮箱是否存在");
	}

	@Before
	public void caseUp() {
		mobileexistsBean=new MobileexistsBean();
		mobileexistsCall=new MobileexistsCall();
		jUserWapper=new JUserWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(mobileexistsCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_mobileexis_001() {
		Logger.start(true,"输入的mobile存在,成功");
		try {
			CreateUserReq cur=new CreateUserReq();
			cur=JUserCallService.initCreateUserBean(cur);
			cur.setMail(TestDataManager.getEmail());
			int uid = JUserCallService.createUserCall(cur);
			mobileexistsBean.setMobile(cur.getMobile());
			mobileexistsCall.setData(mobileexistsBean);
			mobileexistsCall.callService();
			Logger.verifyEquals("true", mobileexistsCall.getString("Success"), "验证是否成功");
			Logger.verifyEquals("200", mobileexistsCall.getString("ResponseCode"), "验证返回code是否正确");
			Logger.verifyEquals("true", mobileexistsCall.getResultData().getResult().getExists(), "验证存在mobil");
			Logger.verifyEquals("3", mobileexistsCall.getResultData().getResult().getExistsCode(), "验证存在existsCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_mobileexis_002() {
		Logger.start(true,"输入的mobile不存,成功");
		try {
			mobileexistsBean.setMobile("-1");
			mobileexistsCall.setData(mobileexistsBean);
			mobileexistsCall.callService();
			Logger.verifyEquals("true", mobileexistsCall.getString("Success"), "验证是否成功");
			Logger.verifyEquals("200", mobileexistsCall.getString("ResponseCode"), "验证返回code是否正确");
			Logger.verifyEquals("false", mobileexistsCall.getResultData().getResult().getExists(), "验证存在mobil");
			Logger.verifyEquals("0", mobileexistsCall.getResultData().getResult().getExistsCode(), "验证存在existsCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_mobileexis_003() {
		Logger.start(true,"不输入mobile,返回不存在mail");
		try {
			mobileexistsCall.setData(mobileexistsBean);
			mobileexistsCall.callService();
			Logger.verifyEquals("false", mobileexistsCall.getString("Success"), "验证是否成功");
			Logger.verifyEquals("400", mobileexistsCall.getString("ResponseCode"), "验证返回code是否正确");
			Logger.verifyEquals("false", mobileexistsCall.getResultData().getResult().getExists(), "验证存在mobil");
			Logger.verifyEquals("0", mobileexistsCall.getResultData().getResult().getExistsCode(), "验证存在existsCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P3.class})
	@TestCase
	public void Tc_mobileexis_004() {
		Logger.start(true,"输入mobile为null,返回不存在mobil");
		try {
			mobileexistsBean.setMobile(null);
			mobileexistsCall.setData(mobileexistsBean);
			mobileexistsCall.callService();
			Logger.verifyEquals("false", mobileexistsCall.getString("Success"), "验证是否成功");
			Logger.verifyEquals("400", mobileexistsCall.getString("ResponseCode"), "验证返回code是否正确");
			Logger.verifyEquals("false", mobileexistsCall.getResultData().getResult().getExists(), "验证存在mobil");
			Logger.verifyEquals("0", mobileexistsCall.getResultData().getResult().getExistsCode(), "验证存在existsCode");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}